﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace EasyCocos2D
{
    public class CCLabelTTF : CCGameObject
    {
        private Label labelTTF;

        public Label TTFlabel
        {
            get { return labelTTF; }
            set { labelTTF = value; }
        }

        public CCLabelTTF(string text)
            : base()
        {
            labelTTF = new Label();
            labelTTF.Text = text;
            labelTTF.BackColor = Color.Black;
        }

        public override string serialineH()
        {
            string s = "";
            s += String.Format("\t\tCCLabelTTF *{0};\n", Name);
            return s;
        }

        public override string serialineCPP()
        {
            string s = "";
            s += String.Format("\t{0} = CCLabelTTF::create(\"{1}\", \"{2}\", {3});\n\t{0}->setColor(ccc3({4}, {5}, {6}));\n\t{0}->setPosition(ccp({7}, {8}));\n", Name, labelTTF.Text, labelTTF.Font.Name, labelTTF.Font.Size, labelTTF.BackColor.A, labelTTF.BackColor.B, labelTTF.BackColor.G, Position.X, Position.Y);
            return s;
        }

        public override bool getObject(System.Drawing.Point p)
        {
            if (Position.X < p.X && p.X < Position.X + labelTTF.Width &&
                Position.Y < p.Y && p.Y < Position.Y + labelTTF.Height)
            {
                return true;
            }

            return false;
        }

        public override void Draw(System.Drawing.Graphics g)
        {
            Point point = new Point();
            point.X = Position.X;
            point.Y = Position.Y;

            Color c = Color.Black;
            Brush b = new SolidBrush(c);

            g.DrawString(labelTTF.Text, labelTTF.Font, b, point);
        }
    }
}
